# 导包
import pymysql

# 创建连接
conn = pymysql.connect(host="127.0.0.1", port=3306, user="root", password="mengyue", database="jiuchao", charset="utf8")
# 创建游标
cursor = conn.cursor()
# 执行sql语句
cursor.execute("select version();")
# 提取结果，打印查看
result = cursor.fetchone()
print("查询结果为:", result[0])
# 关闭游标
cursor.close()
# 关闭连接
conn.close()